/*
 * File:   engine.h
 * Author: dolphinigle
 *
 * Created on December 1, 2011, 2:26 PM
 */

#ifndef ENGINE_H
#define	ENGINE_H

#include <cstdio>
#include <cstdlib>
#include <string>

#include "path.h"

using std::string;

// Abstract class that bridges controller (= parser) with the rest of the
// code.
// The Filesystem should implement this class.
// All of the methods returns a string which will be displayed to the screen
// by view. This string may be error messages or output for the commands.
class Engine {
public:
  // Creates a new empty filesystem at the given REAL path that can store files
  // with total size at most size.
  virtual string Format(const Path& path, size_t size)=0;

  // Mounts a filesystem stored at filesystem_location and mount it to mount
  // point.
  virtual string MountFS(const Path& filesystem_location,
                         const Path& mount_point)=0;

  // Unmounts a filesystem rooted at the given mount_point. Resets current
  // directory to /.
  virtual string Unmount(const Path& mount_point)=0;

  // Shows current directory location in virtual system.
  virtual string Pwd()=0;

  // Lists all files and directories in current directory in virtual system.
  virtual string Ls()=0;

  // Lists all files and directories in the given directory.
  virtual string LsDirectory(const Path& directory)=0;

  // Change current directory in virtual system to a specified new directory.
  virtual string Cd(const Path& directory)=0;

  // Creates a new directory in virtual system.
  virtual string Mkdir(const Path& path)=0;

  // Removes a file / folder in the virtual file system.
  virtual string Rm(const Path& path)=0;

  // Copies a file/folder from virtual system / real system to virtual system /
  // real system. However, does not support copying from real system to
  // real system.
  // If copying folder, then it has to be done recursively by copying the entire
  // content of the folder.
  virtual string Cp(const Path& origin, const Path& destination)=0;

  // Moves a file/folder from virtual system / real system to virtual system /
  // real system. That is:
  // Mv(a, b) is equivalent to
  // Cp(a, b)
  // Rm(a)
  virtual string Mv(const Path& origin, const Path& destination)=0;

  // Displays the content of a file in virtual file system.
  virtual string Cat(const Path& filepath)=0;

  // Displays the status of all mounted file systems:
  // size, free space, used space, file count, folder count, mount point
  virtual string Status()=0;

  // Ends the program. That is, unmounts all currently activate file systems.
  virtual string Exit()=0;
};

#endif	/* ENGINE_H */

